package com.atguigu.demo03;


import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


/**
 * @author gjl
 * @create 2021-04-26 18:09
 * 卖票
 */
public class ThreadPoolExecutorDemo {
    public static void main(String[] args) {
        ExecutorService service = Executors.newFixedThreadPool(3);

        try {
            for (int i = 1; i <= 30; i++) {
                int finalI = i;
                service.submit(()->{

                    System.out.println(Thread.currentThread().getName()+"已卖"+ finalI);
                });
            }
        } finally {
            service.shutdown();
        }
    }
}
